package cn.xiuxius.embedded.model;

import com.fasterxml.jackson.annotation.JsonCreator;

public class STCFlashOptionType extends AbstractFlashOptionType<STCType> {
    public STCFlashOptionType(STCType value, String cmdValue, boolean isDefault) {
        super(value, cmdValue, isDefault);
    }

    public static final STCFlashOptionType DEFAULT = new STCFlashOptionType(STCType.AUTO, "auto", true);

    @JsonCreator
    public static STCFlashOptionType from(Object val) {
        if (val instanceof String s) {
            if ("AUTO".equalsIgnoreCase(s)) {
                return DEFAULT;
            }
            STCType from = STCType.from(s);
            if (from != null) {
                return new STCFlashOptionType(from, s, false);
            }
        }
        throw new IllegalArgumentException("Unsupported stc Type input: " + val);
    }

    @Override
    public String getCmdValue() {
        return getValue().getValue();
    }


    @Override
    public boolean isDefault() {
        return DEFAULT.equals(this);
    }


}
